package com.tang.lease.web.admin.custom.conver;

import com.tang.lease.model.entity.LabelInfo;
import com.tang.lease.model.enums.ItemType;

import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

//@Component
public class StringToItemTypeConverter implements Converter<String, ItemType> {
    @Override
    public ItemType convert(String code) {
        //ItemType[] enumConstants = ItemType.class.getEnumConstants();
        ItemType[] values = ItemType.values();
        for (ItemType value : values) {
            if (value.getCode().equals(Integer.valueOf(code))){
                return value;
            }
        }
        throw new IllegalArgumentException("code非法");
    }
}
